package com.base.study.fragment;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.View;

import com.base.commonlib.base.CBaseMvpFragment;
import com.base.study.R;
import com.base.study.bean.CurriculumIntroduceBean;
import com.base.study.databinding.FragmentCurriculumIntroduceBinding;
import com.base.study.utils.MyImageGetter;
import com.base.study.utils.MyTagHandler;

/**
 * Created by zw on 2020/2/14.
 * 介绍
 */

public class CurriculumIntroduceFragment extends CBaseMvpFragment   {

    protected FragmentCurriculumIntroduceBinding mBinding;
    private CurriculumIntroduceBean curriculumIntroduceBean;

    @Override
    public void init() {
        mBinding = (FragmentCurriculumIntroduceBinding) mRootBinding;

    }

    @Override
    public void start() {
        initData();
    }

    @SuppressLint("SetTextI18n")
    private void initData(){
        Bundle bundle =this.getArguments();
         curriculumIntroduceBean=new CurriculumIntroduceBean();
        curriculumIntroduceBean = (CurriculumIntroduceBean) bundle.get("curriculumIntroduceBean");

        mBinding.introduceScope.setText(curriculumIntroduceBean.getDuration()+"");
        if (!TextUtils.isEmpty(curriculumIntroduceBean.getPrice())){
            mBinding.introducePrice.setText(""+curriculumIntroduceBean.getPrice()+"");
        }else {
            mBinding.introducePrice.setText("00.00");
        }
        mBinding.introducePrice.setVisibility(View.GONE);
        MyImageGetter imageGetter = new MyImageGetter(mContext, mBinding.introduceContent);
        MyTagHandler tagHandler = new MyTagHandler(mContext);
        mBinding.introduceNumbers.setText(curriculumIntroduceBean.getIsCharge()+"");
        mBinding.introduceTitle.setText(curriculumIntroduceBean.getName());
        mBinding.introduceContent.setText(Html.fromHtml(curriculumIntroduceBean.getDescription(),imageGetter,tagHandler));
        mBinding.introduceContent.setMovementMethod(LinkMovementMethod.getInstance());
        //mBinding.introduceContent.setText(Html.fromHtml(curriculumIntroduceBean.getDescription()));
    }

    @Override
    protected int getLayoutResource() {
        return R.layout.fragment_curriculum_introduce;
    }


}
